package com.xn.app.muying.adpter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.xn.app.muying.R;
import com.xn.app.muying.bean.DoctorGsonBean;
import com.xn.app.muying.bean.MineYiYuanBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/11/1.
 */
public class DoctorLeftAdapter extends BaseAdapter{
    private final LayoutInflater inflater;
    private Context context;
    private ArrayList<DoctorGsonBean> list = new ArrayList();
    private String data;

    public DoctorLeftAdapter(Context context) {
        this.context = context;
        inflater = LayoutInflater.from(context);
    }
    public void getData(ArrayList<DoctorGsonBean> data) {
        this.list.addAll(data);
        notifyDataSetChanged();
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder=null;
        if(view==null){
            view = inflater.inflate(R.layout.doctorleftlistview, null);
            holder = new ViewHolder();
            holder.iv = (ImageView) view.findViewById(R.id.doctorleft_iv);
            holder.tv = (TextView) view.findViewById(R.id.doctorleft_tv);
            view.setTag(holder);
        }else {
            holder = (ViewHolder) view.getTag();
        }
        List<DoctorGsonBean.SubCompaniesBean> subCompanies = list.get(1).getSubCompanies();
        ArrayList<String> list = new ArrayList<>();
        for (int j = 0; j < subCompanies.size(); j++) {
            data = subCompanies.get(j).getName();
            list.add(data);
            Log.i("data==",data);
        }
        holder.tv.setText(list.get(i));
        return view;
    }
    class ViewHolder{
        ImageView iv;
        TextView tv;
    }
}
